package entity;
import java.awt.Color;
import boundary.Adapter;
import desktop_fields.Street;

public class Tax extends Field {

	public Tax(String title, String subtitle, String desc, int cnsq){
		super(title,subtitle,desc,cnsq);
	}

	/**
	 * Giver valgmulighed for Tax feltet.
	 * Enten betaler man 10% af sin pengebeholdning eller det tilsvarende felts konsekvens
	 */
	public void landOnField(Spiller spiller){
		if (consequence == 4000){
			boolean choice = Adapter.taxAmount(consequence, (int)(spiller.getKonto().getBalance()*0.1));
			if (choice == true){ 	// Her vælges konsekvensen på feltet
				spiller.getKonto().updBalance(-consequence);
			} 
			else if (choice == false){		// Her vælges 10% betaling
				spiller.getKonto().setBalance((int) (spiller.getKonto().getBalance()*0.9));
			}
		}
		else {
			spiller.getKonto().updBalance(-consequence);
		}
	}

	public desktop_fields.Field createGuiField() {
		Color taxColor = new Color(255, 0, 0);

		desktop_fields.Field f = new Street.Builder()
		.setTitle(title)
		.setSubText(subtitle + consequence)
		.setDescription(description)
		.setFgColor(Color.BLACK)
		.setBgColor(taxColor)
		.setRent("")
		.build();
		return f;
	}
}